package 代码记录.指定公司代码练习记录.华为_2024.分值200;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zx
 * @create 2024-02-16 14:47
 * 自己能看懂的代码
 */
public class 喊7的次数重排_30 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] temp = sc.nextLine().split(" ");
        int[] nums = new int[temp.length];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = Integer.parseInt(temp[i]);
        }
        int sum = 0;
        for (int num : nums) {
            sum += num;
        }
        //sevenNumbers的元素是能被7整除或包含数字7的数字
        int[] sevenNumbers = findSevenNumbers(sum);
        System.out.println(sum);
        System.out.println(Arrays.toString(sevenNumbers));
        int[] res = new int[nums.length + 1];
        for (int num : sevenNumbers) {
            res[num % nums.length]++;
        }
        for (int i = 1; i < res.length; i++) {
            System.out.print(res[i]);
            if (i != res.length - 1) {
                System.out.print(" ");
            }
        }
    }

    /**
     * 查找满足以下条件的整数：能被7整除或包含数字7
     * 在循环中逐个判断数字是否满足条件,将符合条件的数字填充到结果数组中,直到结果数组中元素个数达到指定的次数
     */
    public static int[] findSevenNumbers(int times) {
        int count = 0;
        int num = 1;//第一个人喊的数字从1开始
        int[] res = new int[times];
        while (count < times) {
            if (num % 7 == 0 || String.valueOf(num).contains("7")) {
                res[count] = num;
                count++;
            }
            num++;
        }
        return res;
    }
}
